package com.clj.blesample.menu;

import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.clj.blesample.BaseActivity;
import com.clj.blesample.databinding.ActivityRecordDetailBinding;
import com.clj.blesample.entity.RecordInfo;

public class RecordDetailActivity extends BaseActivity {
    private ActivityRecordDetailBinding mBinding;
    private RecordInfo mRecordInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mRecordInfo = (RecordInfo) getIntent().getSerializableExtra("data");
        mBinding = ActivityRecordDetailBinding.inflate(getLayoutInflater());
        setContentView(mBinding.getRoot());
        setSupportActionBar(mBinding.toolbar);
        getSupportActionBar().setTitle("详情");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mBinding.inputDeviceNo.setContent(mRecordInfo.F_MachineCode);
        mBinding.inputProjectNo.setContent(mRecordInfo.F_ProjectCode);
        mBinding.inputCollectNo.setContent(mRecordInfo.F_WeldNum);
        mBinding.inputAnalysisResult.getEtContent().setTextColor("合格".equals(mRecordInfo.F_AnalysisResult) ? Color.GREEN : Color.RED);
        mBinding.inputAnalysisResult.setContent(TextUtils.isEmpty(mRecordInfo.F_AnalysisResult) ? "异常" : mRecordInfo.F_AnalysisResult);
        mBinding.inputRiskLevel.setContent(mRecordInfo.F_RiskLevel);
    }


    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }
}
